﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BTKERP.MVCWeb.AppCode;
using BTKERP.Model;
using BTKERP.BLL.Inventory;

namespace BTKERP.MVCWeb.Controllers
{
    public class RequisitionDOController : RestrictController
    {
        //
        // GET: /RequisitionDO/
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            ViewBag.CurrentPageId = 4;
        }

        public ActionResult Index()
        {
            ViewData["WareHouseLisst"] = DataRefHelper.GetWareHouseList(false);
            ViewData["UserList"] = GetUserList(SessionEntity.Staff.UserName);
            return View();
        }

        [HttpPost]
        public ActionResult Index(FormCollection collection)
        {
            ViewData["WareHouseLisst"] = DataRefHelper.GetWareHouseList(false);
            ViewData["UserList"] = GetUserList(SessionEntity.Staff.UserName);

            string houseId = collection.Get("house");
            string requId = collection.Get("reqno");
            string doNo = collection.Get("dono");
            string requeBy = collection.Get("UserList");
            int status = int.Parse(collection.Get("status"));

            List<RequisitionDeliveryMaster> master = InventoryActivityMgt.SearchDOMaster(houseId, requId,doNo,requeBy,status);
            return View(master);
        }

        //
        // GET: /RequisitionDO/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /RequisitionDO/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /RequisitionDO/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /RequisitionDO/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /RequisitionDO/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /RequisitionDO/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /RequisitionDO/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
